package com.gaoyang.controller;

import com.gaoyang.domain.User;
import com.gaoyang.service.UserService;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by gaoyang on 2017/6/1.
 */
@RestController
public class UserController {

    //测试配置文件定义参数
    @Value(value = "${gaoyang.secret}")
    private String count;
    //占位符
    @Value(value = "${gaoyang.site}")
    private String name;

    @Autowired
    UserService userService;

    @RequestMapping(value = "/", method = RequestMethod.GET)
    String index() {
        return count + name + new Date();
    }

    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public Map<String, String> get(@RequestParam String name) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("name", name);
        map.put("value", "gaoyang");
        return map;
    }

    @RequestMapping(value = "/getRedis", method = RequestMethod.GET)
    public String getRedis() {
        return userService.getRedisString("gaoyang_aaa");
    }

//    @ApiOperation(value="获取用户信息", notes="通过用户名")
//    @ApiImplicitParam(name = "name", value = "用户名", required = true, dataType = "String")
    @RequestMapping(value = "/test/{name}", method = RequestMethod.GET)
    public User test(@PathVariable String name) {
        return userService.getUser(name);
    }

}
